import { Ref, ref, watchEffect } from 'vue'
import { NumData } from '../types'

/**
 * 各学校未测分布
 */
export function useAllGradeNoTestNum({
  numData,
}: {
  numData: Ref<NumData | null>
}) {
  const gradeNoAxisData = ref<string[]>([])
  const gradeNoSeriesData = ref<any[]>([])

  watchEffect(() => {
    if (!Array.isArray(numData.value?.allGradeNoTestNum)) {
      return
    }
    gradeNoAxisData.value = []
    gradeNoSeriesData.value = []

    numData.value?.allGradeNoTestNum.map((item) => {
      gradeNoAxisData.value.push(item.schoolName)
      gradeNoSeriesData.value.push({ value: item.num, tenantId: item.tenantId })
    })
  })
  return {
    gradeNoAxisData,
    gradeNoSeriesData,
  }
}
